var t = getApp();

Page({
    data: {
        language: "",
        nickname: "",
        avatar: "",
        total_activity: "",
        total_income: "",
        estimate_amount: "",
        unsettlement_amount: "",
        settlement_amount: "",
        nowithdraw_amount: "",
        withdraw_amount: "",
        failure_amount: "",
        activeName: "first",
        activity_list: [],
        status: 3,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var a = this, i = t.getNetAddresss("plugin.commission-activity.api.activity-inquire.index");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                page: this.data.page,
                status: this.data.status
            },
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    var e = i.data.activity;
                    a.setData({
                        nickname: i.data.nickname,
                        avatar: i.data.avatar,
                        total_activity: i.data.total_activity,
                        total_income: i.data.total_income,
                        estimate_amount: i.data.estimate_amount,
                        unsettlement_amount: i.data.unsettlement_amount,
                        settlement_amount: i.data.settlement_amount,
                        nowithdraw_amount: i.data.nowithdraw_amount,
                        withdraw_amount: i.data.withdraw_amount,
                        failure_amount: i.data.failure_amount,
                        activity_list: e.data,
                        page: e.current_page,
                        total_page: e.last_page
                    }), i.data.name && wx.setNavigationBarTitle({
                        title: i.data.name + "查询"
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    _getMoreData: function() {
        var a = this, i = {
            page: this.data.page,
            status: this.data.status
        }, e = "";
        a.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e = t.getNetAddresss("plugin.commission-activity.api.activity-inquire.index"), t._postNetWork({
            url: e,
            showToastIn: !1,
            data: i,
            success: function(t) {
                var i = t.data;
                1 == i.result ? a.setData({
                    isLoadMore: !0,
                    activity_list: a.data.activity_list.concat(i.data.activity.data)
                }) : a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    handleClick: function(t) {
        var a = t.detail.index;
        0 == a ? this.data.status = "3" : 1 == a ? this.data.status = "0" : 2 == a ? this.data.status = "1" : 3 == a && (this.data.status = "-1"), 
        this.getListData();
    },
    getListData: function() {
        var a = this;
        this.isLoadMore = !1, this.page = 1, this.total_page = 0, this.setData({
            activity_list: []
        });
        var i = t.getNetAddresss("plugin.commission-activity.api.activity-inquire.index");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                page: this.data.page,
                status: this.data.status
            },
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    var e = i.data.activity;
                    a.setData({
                        activity_list: e.data,
                        page: e.current_page,
                        total_page: e.last_page
                    });
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    gotoCommision: function(t) {
        var a = t.currentTarget.dataset.num;
        wx.navigateTo({
            url: "/packageB/member/distribution_queue/DistributionCommissionDetail/DistributionCommissionDetail?tag=" + a
        });
    },
    gotoOrder: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/member/orderdetail/orderdetail?order_id=" + a + "&orderType=commission_activity"
        });
    },
    gotoParticipant: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageB/member/distribution_queue/DistributionParticipant/DistributionParticipant?id=" + a
        });
    }
});